<template>
  <div class="dashboard-container">
    <div class="dashboard-text">欢迎你！: {{ cokies }}</div>
    <el-button class="filter-item" type="primary" icon="el-icon-search" @click="search()">查看系统健康监控数据</el-button>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import Cookies from 'js-cookie'

export default {
  name: 'Dashboard',
  data() {
    return {
      cokies: ''
    }
  },
  computed: {
    ...mapGetters([
      'name'
    ])
  },
  created() {
    this.fetchData()
  },
  methods: {
    async fetchData() {
      this.cokies = Cookies.get('username')
    },
    search() {
      this.$confirm('是否前往查看监控页面, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        window.open('http://localhost:8080/druid/index.html')
        this.$message({
          type: 'success',
          message: '成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消！'
        })
      })
      // window.location.href = 'http://localhost:8080/repair/excelList' //  跳转链接
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
